const path = require('path')
const resolve = (dir) => {
  return path.join(__dirname, dir)
}
const px2rem = require('postcss-px2rem')
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  configureWebpack: {
    // 开发服务器
    devServer: {
      proxy: {
        '/api': {
          target: 'https://autumnfish.cn/',
          changeOrigin: true,
          pathRewrite:{
            '^/api': '/' 
          }
        }
      }
    },
    resolve: {
      extensions: ['vue', 'js', 'json'],
      alias: {
        '@': resolve('src'),
        _c: resolve('src/components'),
        _a: resolve('src/assets'),
        _u: resolve('src/utils'),
        _font: resolve('src/assets/font'),
        _css: resolve('src/assets/css'),
        _img: resolve('src/assets/img')
      }
    }
  },
  css: {
    loaderOptions: {
      less: {
        javascriptEnabled: true
      },
      postcss: {
        plugins: [
          px2rem({ remUnit: 16 }) // 基准大小,需要和rem.js中相同
        ]
      }
    }
  },
  // 配置全局less
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [resolve('src/assets/css/common.less')]
    }
  }
}
